#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define uint unsigned int

#define YES cout << "YES" << '\n'
#define NO cout << "NO" << '\n'
#define endl '\n'
const int INF = 1e9;
const int MOD = 998244353;
using namespace std;

/*思考

*/

int a[10001]={0};
int b[10001]={0};
int c[10001]={0};
void gaojingadd(string s1, string s2, int n) {
    int al = s1.size();
    int bl = s2.size();
    int cl = max(al, bl);
    for (int i = 0; i < al; i++) {
        if (s1[i] >= 'A' && s1[i] <= 'Z') {
            a[al - i] = s1[i] - 'A' + 10;
        } else {
            a[al - i] = s1[i] - '0';
        }
    }
    for (int i = 0; i < bl; i++) {
        if (s2[i] >= 'A' && s2[i] <= 'Z') {
            b[bl - i] = s2[i] - 'A' + 10;
        } else {
            b[bl - i] = s2[i] - '0';
        }
    }
    for (int i = 1; i <= cl; i++) {
        c[i] += a[i] + b[i];
        c[i + 1] = c[i] / n;
        c[i] %= n;
    }
    if (c[cl + 1] > 0) cl++;
    for(int i=cl;i>=1;i--){
        if(c[i]>=10){
            cout<<char(c[i]-10+'A');
        }else{
            cout<<c[i];
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    gaojingadd(s1, s2, n);
    return 0;
}